<?php /* Smarty version 2.6.31, created on 2018-04-01 20:55:46
         compiled from E:/xampp/htdocs/rbac/Admin/Tpl/Authority/editAccess.html */ ?>
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "../Common/head_authority.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>
<body>
<div class="container-fluid">
    <div class="row" style="margin: 20px 0px;">
        <b>编辑权限</b>
        <a href="javascript:history.back();" style="float: right;">返回</a>
    </div>
    <form action="#" method="post">
        <div class="row" style="height: 35px;line-height: 35px;margin-top: 15px;">
            <div class="col-sm-2 col-md-2 col-lg-2" style="text-align: right">
                <b>菜单等级</b>
            </div>
            <div class="col-sm-5 col-md-5 col-lg-5">
                <select id="level" name="level" class="form-control">
                    <?php if ($this->_tpl_vars['oldData']['level'] == 0): ?>
                    <option value="0" selected>一级菜单</option>
                    <?php else: ?>
                    <option value="0">一级菜单</option>
                    <?php endif; ?>
                    <?php if ($this->_tpl_vars['oldData']['level'] == 1): ?>
                    <option value="1" selected>二级菜单</option>
                    <?php else: ?>
                    <option value="1">二级菜单</option>
                    <?php endif; ?>
                    <?php if ($this->_tpl_vars['oldData']['level'] == 2): ?>
                    <option value="2" selected>三级菜单</option>
                    <?php else: ?>
                    <option value="2">三级菜单</option>
                    <?php endif; ?>
                </select>
            </div>
        </div>
        <div class="row" style="height: 35px;line-height: 35px;margin-top: 15px;">
            <div class="col-sm-2 col-md-2 col-lg-2" style="text-align: right">
                <b>权限标题</b>
            </div>
            <div class="col-sm-5 col-md-5 col-lg-5">
                <input type="text" name="title" class="form-control" value="<?php echo $this->_tpl_vars['oldData']['title']; ?>
"/>
            </div>
        </div>
        <?php if ($this->_tpl_vars['oldData']['level'] == 0): ?>
        <div class="row" id="icon_box" style="height: 35px;line-height: 35px;margin-top: 15px;">
            <div class="col-sm-2 col-md-2 col-lg-2" style="text-align: right">
                <b>图标类</b>
            </div>
            <div class="col-sm-5 col-md-5 col-lg-5">
                <input type="text" name="icon_class" class="form-control" value="<?php echo $this->_tpl_vars['oldData']['icon_class']; ?>
"/>
            </div>
        </div>
        <?php endif; ?>
        <?php if ($this->_tpl_vars['oldData']['level'] == 1 || $this->_tpl_vars['oldData']['level'] == 2): ?>
        <div class="row" id="parent_box" style="height: 35px;line-height: 35px;margin-top: 15px;">
            <div class="col-sm-2 col-md-2 col-lg-2" style="text-align: right">
                <b>父级菜单</b>
            </div>
            <div class="col-sm-5 col-md-5 col-lg-5">
                <select id="parent_id" name="parent_id" class="form-control">
                    <?php $_from = ($this->_tpl_vars['parentMenu']); if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['v']):
?>
                        <?php if ($this->_tpl_vars['oldData']['parent_id'] == $this->_tpl_vars['v']['id']): ?>
                        <option value="<?php echo $this->_tpl_vars['v']['id']; ?>
" selected><?php echo $this->_tpl_vars['v']['title']; ?>
</option>
                        <?php else: ?>
                        <option value="<?php echo $this->_tpl_vars['v']['id']; ?>
"><?php echo $this->_tpl_vars['v']['title']; ?>
</option>
                        <?php endif; ?>
                    <?php endforeach; endif; unset($_from); ?>
                </select>
            </div>
        </div>
        <div class="row" id="control_box" style="height: 35px;line-height: 35px;margin-top: 15px;">
            <div class="col-sm-2 col-md-2 col-lg-2" style="text-align: right">
                <b>控制器名</b>
            </div>
            <div class="col-sm-5 col-md-5 col-lg-5">
                <input type="text" name="control" class="form-control" value="<?php echo $this->_tpl_vars['oldData']['control']; ?>
"/>
            </div>
        </div>
        <div class="row" id="method_box" style="height: 35px;line-height: 35px;margin-top: 15px;">
            <div class="col-sm-2 col-md-2 col-lg-2" style="text-align: right">
                <b>方法名</b>
            </div>
            <div class="col-sm-5 col-md-5 col-lg-5">
                <input type="text" name="method" class="form-control" value="<?php echo $this->_tpl_vars['oldData']['method']; ?>
"/>
            </div>
        </div>
        <?php endif; ?>

        <div class="row" style="height: 35px;line-height: 35px;margin-top: 15px;">
            <div class="col-sm-2 col-md-2 col-lg-2" style="text-align: right">
            </div>
            <div class="col-sm-5 col-md-5 col-lg-5">
                <button type="submit" class="btn btn-primary pull-right">确定</button>
            </div>
        </div>
    </form>
</body>
<?php echo '
<script>
    $(document).ready(function(){
        $("#level").change(function(){
            var level = $("#level option:selected").val();
            if(level == 1 || level == 2){
                $("#icon_box").css("display","none");
                $("#icon_box").attr("disabled");
                $("#parent_box,#control_box,#method_box").removeAttr("disabled");
                $("#parent_box,#control_box,#method_box").css("display","block");
                $.ajax({
                    type:\'post\',
                    url:\'./admin.php?c=Authority&m=getParentsIdByLevel\',
                    data:{level:level},
                    dataType:\'json\',
                    success:function(data){
                        var html = "";
                        for(var i=0; i<data.length; i++){
                            html += " <option value=\'"+data[i].id+"\'>"+data[i].title+"</option>";
                        }
                        $("#parent_id").html(html);
                    }
                })
            }
            if(level == 0){
                $("#icon_box").css("display","block");
                $("#icon_box").removeAttr("disabled");
                $("#parent_box,#control_box,#method_box").attr("disabled");
                $("#parent_box,#control_box,#method_box").css("display","none");
            }
        })
    })
</script>
'; ?>

</html>